<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒计时</title>
    <script>
        function countDown(time) {
            var target = +new Date(time);
            var nowTime = +new Date(); 
            var remain = (target - nowTime) / 1000;
            var day = parseInt(remain / 60 / 60 / 24);
            var hours = parseInt(remain / 60 / 60 % 24);
            hours = hours < 10 ? '0' + hours:hours
            var min = parseInt(remain / 60 % 60); 
            min = min < 10 ? '0' + min:min
            var sec = parseInt(remain % 60);
            sec = sec < 10 ? '0' + sec:sec

            return '倒计时 ：' + day + ' 天 ' + hours + ' 时 ' + min + ' 分 ' + sec + ' 秒 ！！！！！' 
        };
        countdown = countDown('2021-11-11 11:11:11');
        alert(countdown)
    </script>
</head>
<body>
    
</body>
</html>